<?php

    $groups = array();

    foreach ($object->facilities as $key => $value)
        if ($value != ""):

            $group = new stdClass;
            $group->title = $key;
            $group->attributes = explode(',', $value);
            $group->cnt = strlen($value);

            $groups[] = $group;

    endif;

    sort_attributes($groups);

    foreach ($groups as $group):
        echo "<strong>$group->title:</strong>";
        echo '<ul class="clearfix">';
        foreach ($group->attributes as $attribute):
            echo "<li>" . ucfirst(trim($attribute)) . "</li>";
        endforeach;
        echo '</ul>';
    endforeach;
    